﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;

public partial class Support_Default : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
   {
      lbl_UserID.Text = Profile.Fullname + " (" + Profile.UserName + ")";
      if (!IsPostBack)
      {
         var error = Request.QueryString["error"];
         if (error != null)
         {
            txt_Description.Text = error;
            ddl_Topic.SelectedValue = "Bug Report";
         }

         var option = Request.QueryString["option"];
         if (option != null)
         {
            try
            {
               option = option.Replace("+", " ");
               Response.Write("<!-- " + option + "-->");
               ddl_Topic.SelectedValue = option;
            }
            catch
            {
            }
         }
      }

      if (ScriptManager.IsInAsyncPostBack)
      {
         Page.Validate("sendmessage");

         if (Page.IsValid)
         {
            SmtpClient smtp = new SmtpClient();
            string message = txt_Description.Text;
            smtp.Send(Settings.DefaultEmail, Settings.DefaultEmail,
               ddl_Topic.SelectedValue + " from " + Profile.Fullname + " - " + Profile.UserName,
               message);

            Panel_Thanks.Visible = true;
            Panel_Send.Visible = false;
         }
      }
   }
}
